package com.suray.wcs.service.pojo;

import com.alibaba.fastjson.annotation.JSONField;
import com.suray.basic.wcs.path.core.Node;
import com.suray.basic.wcs.path.enums.DirectionStatus;
import com.suray.wcs.res.enums.PalletStatus;
import com.suray.wcs.res.enums.RgvStatus;
import com.suray.wcs.service.enums.ElectricStatus;
import com.suray.wcs.service.enums.RunningStatus;
import com.suray.wcs.service.pojo.rgv.rgv.protocol.util.RgvCargoStatus;

public class BaseRgv {
    /**
     * 小车当前位置
     */
    @JSONField(serialize = false)
    protected Node curLocation;
    /**
     * 小车当前位置（前端显示用）
     */
    protected String curLocationStr;
    /**
     * 电池剩余量(百分制)
     */
    protected Integer battery;
    /**
     * 小车是否载重, 详见{@link PalletStatus}
     */
    protected PalletStatus palletStatus;
    /**
     * 小车换向状态, 详见{@link DirectionStatus}
     */
    protected DirectionStatus directionStatus;
    /**
     * 小车行驶方向
     */
    protected Integer direction;
    /**
     * 小车运行状态, 详见{@link RunningStatus}
     */
    protected RunningStatus runningStatus;
    /**
     * 小车状态, 详见{@link RgvStatus}WCS自身状态
     */
    protected RgvStatus rgvStatus = RgvStatus.OFF_LINE;
    /**
     * res任务结果码
     */
    protected Integer resTaskResult;
    /**
     * 小车状态, 详见{@link RgvStatus}RES自身状态
     */
    protected RgvStatus rgvResStatus = RgvStatus.OFF_LINE;
    /**
     * 小车电量状态, 详见{@link ElectricStatus}
     */
    protected ElectricStatus electricStatus;
    /**
     * 地图版本是否一致
     */
    protected boolean isSameMapVersion;
    /**
     * 当前段序号
     */
    protected Integer currSegment;
    /**
     * 小车当前段终点坐标
     */
    protected Integer segmentLocation;

    /**
     * 故障描述
     */
    protected String errorMessage;

    /**
     * 小车扫到的码
     */
    protected String groundCode;

    /**
     * 地码位置
     */
    protected String locationCode;

    /**
     * 1方向障碍物感知
     * 0:正常; 1:有障碍物 2:未开启
     */
    protected Integer barrierAtOne;
    /**
     * 2方向障碍物感知
     * 0:正常; 1:有障碍物 2:未开启
     */
    protected Integer barrierAtTwo;
    /**
     * 3方向障碍物感知
     * 0:正常; 1:有障碍物 2:未开启
     */
    protected Integer barrierAtThree;
    /**
     * 4方向障碍物感知
     * 0:正常; 1:有障碍物 2:未开启
     */
    protected Integer barrierAtFour;
    /**
     * 是否有托盘（顶部）
     * 1.有货,标准位置(三个光电都有信号) 2.无货（三个光电全无信号） 3.有货但未校准（有且只有一个或两个光电有信号）
     */
    protected RgvCargoStatus hasPallet;

    /**
     * 小车网络延迟时间
     */
    private Integer ping;


    public DirectionStatus getDirectionStatus() {
        return directionStatus;
    }

    public void setDirectionStatus(DirectionStatus directionStatus) {
        this.directionStatus = directionStatus;
    }

    public PalletStatus getPalletStatus() {
        return palletStatus;
    }

    public Integer getResTaskResult() {
        return resTaskResult;
    }

    public void setResTaskResult(Integer resTaskResult) {
        this.resTaskResult = resTaskResult;
    }

    public void setPalletStatus(PalletStatus palletStatus) {
        this.palletStatus = palletStatus;
    }

    public Integer getDirection() {
        return direction;
    }

    public void setDirection(Integer direction) {
        this.direction = direction;
    }

    public RunningStatus getRunningStatus() {
        return runningStatus;
    }

    public void setRunningStatus(RunningStatus runningStatus) {
        this.runningStatus = runningStatus;
    }

    public RgvStatus getRgvStatus() {
        return rgvStatus;
    }

    public void setRgvStatus(RgvStatus rgvStatus) {
        this.rgvStatus = rgvStatus;
    }

    public Integer getBattery() {
        return battery;
    }

    public void setBattery(Integer battery) {
        this.battery = battery;
    }

    public Node getCurLocation() {
        return curLocation;
    }

    public void setCurLocation(Node curLocation) {
        this.curLocation = curLocation;
    }

    public String getCurLocationStr() {
        if (curLocation != null) {
            return curLocation.toString();
        } else {
            return null;
        }
    }

    public void setCurLocationStr(String curLocationStr) {
        this.curLocationStr = curLocationStr;
    }

    public ElectricStatus getElectricStatus() {
        return electricStatus;
    }

    public void setElectricStatus(ElectricStatus electricStatus) {
        this.electricStatus = electricStatus;
    }

    public RgvStatus getRgvResStatus() {
        return rgvResStatus;
    }

    public void setRgvResStatus(RgvStatus rgvResStatus) {
        this.rgvResStatus = rgvResStatus;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public String getGroundCode() {
        return groundCode;
    }

    public void setGroundCode(String groundCode) {
        this.groundCode = groundCode;
    }

    public String getLocationCode() {
        return locationCode;
    }

    public void setLocationCode(String locationCode) {
        this.locationCode = locationCode;
    }

    public String getFullGroundCode() {
        if (groundCode == null) {
            return null;
        }

        return groundCode + locationCode;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public Integer getBarrierAtOne() {
        return barrierAtOne;
    }

    public void setBarrierAtOne(Integer barrierAtOne) {
        this.barrierAtOne = barrierAtOne;
    }

    public Integer getBarrierAtTwo() {
        return barrierAtTwo;
    }

    public void setBarrierAtTwo(Integer barrierAtTwo) {
        this.barrierAtTwo = barrierAtTwo;
    }

    public Integer getBarrierAtThree() {
        return barrierAtThree;
    }

    public void setBarrierAtThree(Integer barrierAtThree) {
        this.barrierAtThree = barrierAtThree;
    }

    public Integer getBarrierAtFour() {
        return barrierAtFour;
    }

    public void setBarrierAtFour(Integer barrierAtFour) {
        this.barrierAtFour = barrierAtFour;
    }

    public RgvCargoStatus getHasPallet() {
        return hasPallet;
    }

    public void setHasPallet(RgvCargoStatus hasPallet) {
        this.hasPallet = hasPallet;
    }

    public Integer getPing() {
        return ping;
    }

    public void setPing(Integer ping) {
        this.ping = ping;
    }

    public void offLinePing() {
        this.ping = null;
    }
}
